package com.example.homeworktagger.config;

import io.milvus.client.MilvusServiceClient;
import io.milvus.param.ConnectParam;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Milvus向量数据库配置类
 * 
 * 负责创建并配置Milvus客户端连接，从配置文件中读取连接参数
 */
@Configuration
public class MilvusConfig {

    /** Milvus服务器主机地址 */
    @Value("${milvus.host}")
    private String host;

    /** Milvus服务器端口 */
    @Value("${milvus.port}")
    private int port;

    /** Milvus数据库名称 */
    @Value("${milvus.database:default}")
    private String database;

    /**
     * 创建Milvus客户端Bean
     * 
     * @return 配置好的MilvusServiceClient实例
     */
    @Bean
    public MilvusServiceClient milvusClient() {
        ConnectParam connectParam = ConnectParam.newBuilder()
                .withHost(host)
                .withPort(port)
                .withDatabaseName(database)
                .build();
        return new MilvusServiceClient(connectParam);
    }
} 